<template>
  <div class="left-chart-2">
    <div class="lc2-header">TDI关键工艺指标</div>
    <!--<div class="lc2-details">设备运行总数<span>245</span></div>-->
    <dv-charts class="lc2-chart chart_left" :option="option1" />
    <dv-charts class="lc2-chart chart_right" :option="option2" />
    <dv-scroll-board :config="config" style="width:350px;height:220px;position: relative;top: 180px;" />
    <dv-decoration-2 style="height:10px;position: relative;top: 200px;" />
  </div>
</template>

<script>
export default {
  name: 'LeftChart2',
  data () {
    return {
      chartsValue: 10,
      option1: {
        title: {
          // text: '',
          style: {
            fill: '#fff'
          }
        },
        series: [
          {
            type: 'gauge',
            data: [ { name: 'itemA', value: 10 } ],
            center: ['50%', '55%'],
            axisLabel: {
              formatter: '{value}%',
              style: {
                fill: '#fff'
              }
            },
            axisTick: {
              style: {
                stroke: '#fff'
              }
            },
            animationCurve: 'easeInOutBack'
          }
        ]
      },
      option2: {
        title: {
          // text: '',
          style: {
            fill: '#fff'
          }
        },
        series: [
          {
            type: 'gauge',
            data: [ { name: 'itemA', value: 10 } ],
            center: ['50%', '55%'],
            axisLabel: {
              formatter: '{value}%',
              style: {
                fill: '#fff'
              }
            },
            axisTick: {
              style: {
                stroke: '#fff'
              }
            },
            animationCurve: 'easeInOutBack'
          }
        ]
      },
      config: {
        // header: ['时间', '病害信息', '数量', '标段'],
        data: [
          ['行1列1', '行1列2', '行1列3'],
          ['行2列1', '行2列2', '行2列3'],
          ['行3列1', '行3列2', '行3列3'],
          ['行4列1', '行4列2', '行4列3'],
          ['行5列1', '行5列2', '行5列3'],
          ['行6列1', '行6列2', '行6列3'],
          ['行7列1', '行7列2', '行7列3'],
          ['行8列1', '行8列2', '行8列3'],
          ['行9列1', '行9列2', '行9列3'],
          ['行10列1', '行10列2', '行10列3']
        ],
        index: true,
        columnWidth: [60, 90, 90],
        align: ['center'],
        rowNum: 5,
        headerBGC: '#1a88ff',
        headerHeight: 45,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)'
      }
    }
  },
  mounted: function () {
    let that = this;
    setInterval(()=>{
      that.option1 = {
        series: [
          {
            type: 'gauge',
            data: [ { name: 'itemA', value: parseInt(10 + (90 - 10) * (Math.random())) } ],
            center: ['50%', '55%'],
            axisLabel: {
              formatter: '{value}%',
              style: {
                fill: '#fff'
              }
            },
            axisTick: {
              style: {
                stroke: '#fff'
              }
            },
            animationCurve: 'easeInOutBack'
          }
        ]
      };
    }, 2000);
    setInterval(()=>{
      that.option2 = {
        series: [
          {
            type: 'gauge',
            data: [ { name: 'itemA', value: parseInt(10 + (90 - 10) * (Math.random())) } ],
            center: ['50%', '55%'],
            axisLabel: {
              formatter: '{value}%',
              style: {
                fill: '#fff'
              }
            },
            axisTick: {
              style: {
                stroke: '#fff'
              }
            },
            animationCurve: 'easeInOutBack'
          }
        ]
      };
    }, 2000);
  },
  methods: {

  }
}
//parseInt(10 + (90 - 10) * (Math.random()))
</script>

<style lang="less">
.left-chart-2 {
  width: 100%;
  height: 30%;
  display: flex;
  flex-direction: column;
  position: relative;
  top: 205px;
}

  .lc2-header {
    height: 20px;
    line-height: 20px;
    font-size: 16px;
    text-indent: 20px;
    margin-top: 10px;
  }

  .lc2-details {
    height: 40px;
    font-size: 16px;
    display: flex;
    align-items: center;
    text-indent: 20px;

    span {
      color: #096dd9;
      font-weight: bold;
      font-size: 35px;
      margin-left: 20px;
    }
  }

  .lc2-chart {
    width: 200px !important;
    height: calc(~"100% - 80px") !important;
  }

  .chart_left {
    position: absolute !important;
    top: 30px;
    left: -10px;
  }
  .chart_right {
    position: absolute !important;
    top: 30px;
    left: 155px;
  }

</style>
